package com.zhuiyun.educations.api.record.mapper;

import com.zhuiyun.educations.api.record.entity.Record;
import com.zhuiyun.educations.common.mapper.BaseMapper;
import com.zhuiyun.educations.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName RecordMapper
 * @Description TODO 开通会员管理
 * @Author ys
 * @Date 2023/6/20 14:35
 **/
public interface RecordMapper extends BaseMapper<Record> {
    /**
     * @Author ys
     * @Description TODO 分页查询
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Select("select *,TIMESTAMPDIFF(DAY, now(), r.close_time) as residue_time from record r,user u,member m where r.user_id=u.id and r.member_id=m.id and r.del_flag=0")
    List<Record> getRecord(PageRequest pageRequest);
    /**
     * @Author ys
     * @Description TODO 逻辑删除
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Update("update record set del_flag=1 where id=#{id}")
    int deleteRecordById(int id);
    /**
     * @Author ys
     * @Description TODO 开通用户下拉
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Select("SELECT * FROM user")
    List<Record> userSelect();
    /**
     * @Author ys
     * @Description TODO 会员类型下拉
     * @Date 2023/6/26 14:09
     * @Return CommonResult
     * @param
     */
    @Select("SELECT * FROM  member where del_flag=0")
    List<Record> memberSelect();
}
